<!doctype html>
<html lang="en" class="no-js">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<?php include __DIR__."../PHP/db.php"; ?>
    
<link href="css/boot.css" rel='stylesheet' type='text/css'>
<link href="css/h-style.css" rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>

	<link rel="stylesheet" href="css/reset.css"> <!-- CSS reset -->
	<link rel="stylesheet" href="css/style.css"> <!-- Gem style -->
	<script src="js/modernizr.js"></script> <!-- Modernizr -->

<script>

function validatesignupform() {
    var x = document.myform2.signuser.value;
    var y = document.myform2.signpass.value;
	var z = document.myform2.signemail.value;

	
	if (x == null || x == "") {
        alert("Username must be filled out");
        return false;
    }
	
	if(z == null || z == "")
	{
	  	alert("Email must be filled out");
        return false;	
	}	

	if(y == null || y == "")
	{
	 	alert("Password must be filled out");
     	return false;	
	}	
	if(document.myform2.trm.checked == false)
	{
	alert("Please check the term and agreements");
    return false;	
	}	
	return (true);
	
}

function validatelogform(){
	
	
	var x = document.myform.username.value;
    var y = document.myform.password.value;
	
	
	if (x == null || x == "") {
        alert("Username must be filled out");
        return false;
    }
	
	if(y == null || y == "")
	{
	 	alert("Password must be filled out");
     	return false;	
	}	
	return (true);
	}
	

</script>


<?php

	
if ($_SESSION['login'] != NULL)
{	
	$getdata = $_SESSION['login'];
	$user = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`accounts` WHERE `user`='$getdata'"));
	
	$getlevelofuser = $user['level_no'];
	$_SESSION['level'] = $getlevelofuser;

	if ($getlevelofuser == '2')
	{
		header("Location: Employer/employer.php");
	}
	else if ($getlevelofuser == '3')
	{
		header("Location: applicant/index.php");
	}
}
else
{
								
error_reporting(0);

if($_POST['loginbutton'])
{
		if($_POST['username'] && $_POST['password'])
		{
			$username = mysql_real_escape_string($_POST['username']);
			$password = md5($_POST['password']);
			$user = mysql_fetch_array(mysql_query("SELECT * FROM `accounts` WHERE `user`='$username'"));
			if ($user == '0')
			{	
				?>
                <script type="text/javascript">
					alert("Please double check your username and password");
				</script>
                <?php
            	}
			else{
					if ($user['pass'] != $password){
					?>
						<script type="text/javascript">
        	    	        alert("Please double check your username and password");
    	            	</script>
                    <?php
						}
					else
					{
						if($user['level_no'] == '2')
							{
								if(isset($_POST['loginbutton']))
								{
									$getaccountid = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`accounts` where `user` = '$username' AND `pass` = '$password'"));
									$empid = $getaccountid['account_id'];
									$getstatus = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`employer` where `employer_id` = '$empid'"));
									$status = $getstatus['e_statusid'];
									if($status == '1')
									{
										echo '<script type="text/javascript">
												alert("The administrator is still verifying your account. Please do check your email regularly"); 
												document.myform.password.focus();
											 </script>';
										}
									else if($staus == '4')
									{
										echo '<script type="text/javascript">
												alert("Your Account is blocked due to some instance."); 
												document.myform.signin-password.focus();
											 </script>';
										
										}
									else if($status == '3')
									{
										echo '<script type="text/javascript">
												alert("Your Account was declined by the administrator due to some instance."); 
												document.myform.signin-password.focus();
											 </script>';
										
										}
									else
									{
									$_SESSION['login'] = $_POST['username'];
									$getdata = $_SESSION['login'];
									$user = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`accounts` WHERE `user`='$getdata'"));
									$getlevelofuser = $user['level_no'];
									$_SESSION['level'] = $getlevelofuser;
									header("location: Employer/employer.php"); 
									exit();
									}
								}
								
							}
						else if($user['level_no'] == '3')
							{
							if(isset($_POST['loginbutton']))
								{
								$getaccountid = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`accounts` where `user` = '$username' AND `pass` = '$password'"));
								$appid = $getaccountid['account_id'];
								$getstatus = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`applicant` where `applicant_id` = '$appid'"));
								$status = $getstatus['a_status'];
									if($status == '4')
									{
										echo '<script type="text/javascript">
													alert("Your Account was blocked by the administrator due to some instance."); 
													document.myform.signin-password.focus();
												 </script>';	
										}
									else
									{
									$_SESSION['login'] = $_POST['username'];
									$getdata = $_SESSION['login'];
									$user = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`accounts` WHERE `user`='$getdata'"));
									$getlevelofuser = $user['level_no'];
									$email = $user['emailadd'];
									$_SESSION['level'] = $getlevelofuser;
									$applicant = mysql_fetch_array(mysql_query("SELECT * FROM `flss`.`applicant` WHERE `email`='$email'"));
									$_SESSION['applicant_id'] = $applicant['applicant_id'];
									$_SESSION['fullname'] = $applicant['fname'].' '.$applicant['lname'];
									header("location: applicant/index.php");
									exit();
									}
								}
							
								
						
							}
						else
							{
							header("location: admin/adminpage.html");
							
							}
			
	
					}
					
				}	
		}
	} 
 
else if($_POST['signbutton'])
{
		if($_POST['signuser'] && $_POST['signpass'])
		{
			$signusername = mysql_real_escape_string($_POST['signuser']);
			$signpassword = md5($_POST['signpass']);
			$signemail = $_POST['signemail'];
			$signhr = $_POST['signhr'];
			$signno = $_POST['signno'];
			
			$check = mysql_fetch_array(mysql_query("SELECT * FROM `accounts` WHERE `user`='$signusername'"));
			$checkemail = mysql_fetch_array(mysql_query("SELECT `emailadd` FROM `accounts` WHERE `emailadd`='$signemail'"));
			if ($check != '0')
			{	echo '<script type="text/javascript">alert("Username was already used");</script>';
			}
			else
			{
				if ($checkemail != '0')
				{	echo '<script type="text/javascript">alert("Email was already used");</script>';
				}
				else
				{
					if(!ctype_alnum($signusername)){
					echo '<script type="text/javascript">alert("Username contains invalid character");</script>';
					}
					else
					{
						if (strlen($signusername) > 20){
						echo '<script type="text/javascript">alert("Username exceeds to 20 character");</script>';
						}
						else
						{
							$empl = '';
							if ($_POST['emp'] == 'checked')
							{	$empl = 2;
							$refid = uniqid();
							mysql_query("INSERT INTO `flss`.`accounts` (`account_id`, `level_no`, `user`, `pass`, `emailadd`) VALUES (NULL, '$empl', '$signusername', '$signpassword', '$signemail') ") or die(mysql_error());
							$accid = mysql_fetch_array(mysql_query("SELECT `account_id` FROM `flss`.`accounts` WHERE `user`='$signusername'"));
							$containaccount = $accid['account_id'];
							mysql_query("INSERT INTO `flss`.`employer` (`employer_id`, `e_statusid`, `ename`, `hr_name`, `contact`, `email`, `description`, `whyjoinus`, `refid`) VALUES ('$containaccount', '1', 'Company Name', '$signhr', '$signno', '$signemail', '', '' , '$refid')") or die(mysql_error());
							mysql_query("INSERT INTO `flss`.`e_archives` (`employer_id`, `e_status`, `datestart`, `datelast`) VALUES ('$containaccount', '', '', '')");
							mysql_query("INSERT INTO `flss`.`e_snap` (`e_id`, `Registration_No`, `Industry`, `Company_size`, `Working_hours`, `Dresscode`, `Benefits`, `Spoken_language`) 
							VALUES ('$containaccount', '', '', '', '', '', '', '')");
							mysql_query("INSERT INTO `e_address`(`employer_id`, `e_address`) VALUES ('$containaccount','')");
							mysql_query("INSERT INTO `e_map`(`employer_id`, `e_address`) VALUES ('$containaccount','')");
							
							echo '<script type="text/javascript">alert("Check your email. FLSS Admin will verify your company.");</script>';

							$to = getEmail($containaccount);
							$employer_name = getName($containaccount);	

							sendEmail($to,aftersu($employer_name),"We are validating your registration, thank you!");

							}
							else
							{	$empl = 3;
								$refida = uniqid();
								mysql_query("INSERT INTO `flss`.`accounts` (`account_id`, `level_no`, `user`, `pass`, `emailadd`) VALUES (NULL, '$empl', '$signusername', '$signpassword', '$signemail') ") or die(mysql_error());
								$accid = mysql_fetch_array(mysql_query("SELECT `account_id` FROM `flss`.`accounts` WHERE `user`='$signusername'"));
								$containaccount = $accid['account_id'];
								mysql_query("INSERT INTO `flss`.`applicant` (`applicant_id`, `a_status`, `fname`, `mname`,
								 			`lname`, `email`, `age`, `gender`, `tel`, `mobile`, `civilstatus`,
											`religion`, `dob`, `pob`, `children`, `weight`, `height`, `nationality`,
											`mother`, `father`, `job_id`, `photo`, `refid`, `Resume_Updated`) 
											VALUES ($containaccount, 'new', '', '', '', '$signemail', '', '', '', '',
											 '', '', '', '', '', '', '', '', '', '', '', '', '$refida', NULL);
											") or die(mysql_error());
								mysql_query("INSERT INTO `flss`.`applicant_archives` (`applicant_id`, `a_status`, `datestart`,
											`datelast`) VALUES ('$containaccount', '', '', '')");
								mysql_query("INSERT INTO `flss`.`a_address` (`applicant_id`, `a_address`, `city`, `country`, `Street`) VALUES ('$containaccount', '', '', '', '')");
								mysql_query("INSERT INTO `flss`.`passport` (`applicant_id`, `number`, `issue_date`, `expiry_date`, `placeofissue`) VALUES ('$containaccount', '', '', '', '')");
								echo '<script type="text/javascript">alert("Account successfully created please do log in");</script>';
						
							}
							
						}
					}
				}
			}
		}	
	} 
 
}

?>	
    
    
<title>FLSS</title>
</head>
<body>
	<header role="banner">
		<div id="cd-logo"><a href="#"><img src="images/Logo.jpg" alt="Logo"></a></div>

		<nav class="main-nav">
			<ul>
				<!-- inser more links here -->
				<li><a class="cd-signin" href="#0" ><font size="+2"> Sign in</a></li>
				<li><a class="cd-signup" href="#0" >Sign up</a></li>
                </font>
			</ul>
		</nav>
	</header>

	<div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
		<div class="cd-user-modal-container"> <!-- this is the container wrapper -->
			<ul class="cd-switcher">
				<li><a href="#0">Sign in</a></li>
				<li><a href="#0">New account</a></li>
			</ul>
<!-- get data -->
			<div id="cd-login"> <!-- log in form -->
				<form class="cd-form"  method="post" name="myform" onsubmit="return (validatelogform())">
					<p class="fieldset" id="errorMsg">
						
                    </p>

                    <p class="fieldset">
						<label class="image-replace cd-username" for="signin-username">Username</label>
						<input class="full-width has-padding has-border" name="username" id="signup-username" type="text" placeholder="Username" required>
						<span class="cd-error-message">Error message here!</span>
					</p>

					<p class="fieldset">
						<label class="image-replace cd-password" for="signin-password">Password</label>
						<input class="full-width has-padding has-border" name="password" id="signin-password" type="text"  placeholder="Password" required>
						<a href="#0" class="hide-password">Hide</a>
						<span class="cd-error-message">Error message here!</span>
					</p>

					<p class="fieldset">
						<input type="checkbox" id="remember-me" checked>
						<label for="remember-me">Remember me</label>
					</p>

					<p class="fieldset">
						<input class="full-width" type="submit" name="loginbutton" value="Login">
					</p>
				</form>
				
				<p class="cd-form-bottom-message"><a href="#0">Forgot your password?</a></p>
				<!-- <a href="#0" class="cd-close-form">Close</a> -->
			</div> <!-- cd-login -->

			<div id="cd-signup"> <!-- sign up form -->
				<form class="cd-form" action='' method="post" name="myform2" onSubmit="return (validatesignupform())">
					<p class="fieldset">
						<label class="image-replace cd-username" for="signup-username">Username</label>
						<input class="full-width has-padding has-border"  name="signuser" id="signup-username" type="text" placeholder="Username" required>
						<span class="cd-error-message">Error message here!</span>
					</p>

					<p class="fieldset">
						<label class="image-replace cd-email" for="signup-email">E-mail</label>
						<input class="full-width has-padding has-border" name="signemail" id="signup-email" type="email" placeholder="E-mail" required>
						<span class="cd-error-message">Error message here!</span>
					</p>

					<p class="fieldset">
						<label class="image-replace cd-password" for="signup-password">Password</label>
						<input class="full-width has-padding has-border" name="signpass" id="signup-password" type="text"  placeholder="Password" required>
						<a href="#0" class="hide-password">Hide</a>
						<span class="cd-error-message">Error message here!</span>
					</p>
                    
                    <div id="employer_div">
                    <p class="fieldset">
						<label class="image-replace cd-username" for="signup-hrname">HR Name</label>
						<input class="full-width has-padding has-border"  name="signhr" id="signup-hrname" type="text" placeholder="HR Full Name" >
						<span class="cd-error-message">Error message here!</span>
					</p>
					<p class="fieldset">
						<label class="image-replace cd-number" for="signup-no">Contact Number</label>
						<input class="full-width has-padding has-border"  name="signno" id="signup-no" type="text" placeholder="Contact Number" >
						<span class="cd-error-message">Error message here!</span>
					</p>
					</div>
                    
                    
					<p class="fieldset">
						<input type="checkbox" class="chkBox" value="impchecked" name="trm" id="accept-terms" required>
						<label for="accept-terms">I agree to the <a href="../FLSS/account_template/index.html?#tou">Terms</a></label>
						<label style="float:right;" for="employer"> check if you are an employer</label>
					<input style="float:right; margin-right:2px;" value="checked" name="emp" type="checkbox" id="employer" >
						
                    </p>

					<p class="fieldset">
						<input class="full-width has-padding" type="submit" name="signbutton" value="Create account">
					</p>
				</form>

				<!-- <a href="#0" class="cd-close-form">Close</a> -->
			</div> <!-- cd-signup -->

			<div id="cd-reset-password"> <!-- reset password form -->
				<p class="cd-form-message">Lost your password? Please enter your email address. You will receive a link to create a new password.</p>

				<form class="cd-form">
					<p class="fieldset">
						<label class="image-replace cd-email" for="reset-email">E-mail</label>
						<input class="full-width has-padding has-border" name="resetemail" id="reset-email" type="email" placeholder="E-mail" required>
						<span class="cd-error-message">Error message here!</span>
					</p>

					<p class="fieldset">
						<input class="full-width has-padding" type="submit" value="Reset password">
					</p>
				</form>

				<p class="cd-form-bottom-message"><a href="#0">Back to log-in</a></p>
			</div> <!-- cd-reset-password -->
			<a href="#0" class="cd-close-form">Close</a>
		</div> <!-- cd-user-modal-container -->
	</div> <!-- cd-user-modal -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/main.js"></script> <!-- Gem jQuery -->




<div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
        <li data-target="#myCarousel" data-slide-to="3"></li>
      </ol>
      <div class="carousel-inner" role="listbox">
        <div class="item active">
          <img src="images\Dubai.jpg" alt="First slide">
          <div class="container">
            <div class="carousel-caption">
              <font size="+5"><h1><b>DEFINITELY DUBAI</b></h1></font>
              <p> </p>
            </div>
          </div>
        </div>
        <div class="item">
          <img src="images\Philippines.jpg" alt="Second slide">
          <div class="container">
            <div class="carousel-caption">
              <font size="+5"><h1><b>IT'S MORE FUN IN THE PHILIPPINES</b></h1></font>
              <p></p>
            </div>
          </div>
        </div>
        <div class="item">
          <img src="images\Indonesia.jpg" alt="Third slide">
          <div class="container">
            <div class="carousel-caption">
              <font size="+5"><h1><b>WONDERFUL INDONESIA</b></h1></font>
              <p></p>
            </div>
          </div>
        </div>
        <div class="item">
          <img src="images\Bangladesh.jpg" alt="Fourth slide">
          <div class="container">
            <div class="carousel-caption">
              <font size="+4"><h1><b>BEAUTIFUL BANGLADESH</b></h1></font>
              <p></p>
            </div>
          </div>
        </div>
      </div>
      <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
    
    
    <div class="center_content">
        <div class="home_section_left">
            <img src="images/icon1.gif" alt="" title="" class="home_section_icon" border="0">
                            
                <h2 class="home_title">What we do</h2>
                <div class="home_subtitle">Get to know what we are doing</div>
 
                <div class="home_section_thumb">
                <img src="images/p1.2.jpg" alt="" title="" border="0">
                </div>
                <p><span>"Manpower Consultancy"</span><br>
                FLSS provides a whole gamut of personnel from un-skilled to the highly skilled workers from construction, commissioning and ...
                <br><br>
                <span>"Jobs that we offer"</span><br>
                FLSS supplies limitless number of personnel to its clients from various fields such as Architecture, Medical, Electrical, Mechanical, Engineering, etc..
                </p>
                <a href="../FLSS/account_template/index.html?#wwu" class="more"><img src="images/more.gif" alt="" title="" border="0"></a>
        <div class="clear"></div>
        </div>
        
        
        <div class="home_section_left">
            <img src="images/icon2.gif" alt="" title="" class="home_section_icon" border="0">
                            
                <h2 class="home_title">Who we are</h2>
                <div class="home_subtitle">Get to know us</div>
    
                <div class="home_section_thumb">
                <img src="images/p2.1.jpg" alt="" title="" border="0">
                </div>
                <p><span>Knowing the company</span><br>
                FLSS is a international manpower agency that is based in Dubai and authorized by the Ministry of Labour of the UAE. FLSS is 100% locally owned ... 
                <br> <br>
                <span>Business with the company</span><br>
                For Employers: Post Job Offers, Search for Qualified Applicants, and ...
                </p>
                <a href="../FLSS/account_template/index.html?#tc" class="more"><img src="images/more.gif" alt="" title="" border="0"></a>
        <div class="clear"></div>
        </div>
        
        <div class="home_section_left">
            <img src="images/icon3.gif" alt="" title="" class="home_section_icon" border="0">
                            
                <h2 class="home_title">Search for Jobs</h2>
                <div class="home_subtitle">Immidiately search for jobs</div>
    
                <div class="home_section_thumb">
                <img src="images/p3.1.jpg" alt="" title="" border="0">
                </div>
                <p><span>Search for Jobs</span><br>
                <span>
                 <form action="thecompany.php" method="get">
              	 <input type="search" class="form-control" name="qwertyuiop"  placeholder="Search..."></form>
                 
                </span>
                
        <div class="clear"></div>
        </div>
     	</div>   
    
        <div class="clear"></div>
        </div>
    
    <div class="footer-section">
    <div class="container">
    <div class="row">
    <div id="footer-accordion" class="footer-panel">
    <div class="col-lg-3 col-md-3 col-sm-12 panel footer-item-panel">
    <div class="panel-heading">
    <div class="panel-title">
	<div id="footer-FLSS-title" data-toggle="collapse" data-parent="#footer-accordion" class="footer-title-default">About FLSS</div>
    </div>
    </div>
    <div id="footer-FLSS-desc" class="panel-collapse collapse in" style="height: auto;">
    <ul class="list-unstyled footer-link">
    <li><a href="account_template/index.html?#tc" id="footer-about-us">The Company</a></li><br>
    <li><a href="account_template/index.html?#itn" id="footer-press-releases">In the News</a><br>
	</li>
    <li><a href="account_template/index.html?#wwu" id="footer-work-with-us">Work with Us</a></li><br>
    <li><a href="account_template/index.html?#cu" id="footer-contact-us">Contact Us</a></li><br>
    </ul>
    </div>
    </div>
    <div class="col-lg-3 col-md-3 col-sm-12 panel footer-item-panel">
    <div class="panel-heading">
    <div class="panel-title">
    <div id="footer-jobseekers-title" data-toggle="collapse" data-parent="#footer-accordion" class="footer-title-default">JobSeekers</div>
    </div>
    </div>
    <div id="footer-jobseekers-desc" class="panel-collapse collapse in" style="height: auto;">
    <ul class="list-unstyled footer-link">
    <li><a href="account_template/index.html?#tou" id="footer-jobseeker-term-use">Terms of Use</a></li><br>
    <li><a href="account_template/index.html?#pp" id="footer-jobseeker-privacy-policy">Privacy Policy</a></li><br>
    <li><a href="account_template/index.html?#sjsg" id="footer-jobseeker-safe-guide">Safe Job Search Guide</a></li><br>
    </ul>
    </div>
    </div>
    <div class="col-lg-3 col-md-3 col-sm-12 panel footer-item-panel">
    <div class="panel-heading">
    <div class="panel-title">
    <div id="footer-employers-title" data-toggle="collapse" data-parent="#footer-accordion" class="footer-title-default">Employers</div>
    </div>
    </div>
    <div id="footer-employers-desc" class="panel-collapse collapse in" style="height: auto;">
    <ul class="list-unstyled footer-link">
    <li><a href="" id="footer-employer-post-ad">Post a Job Ad</a></li><br>
    <li><a href="" id="footer-employer-search-resumes">Search for Resumes</a></li><br>
    <li><a href="account_template/index.html?#tou" id="footer-employer-term-use">Terms of Use</a></li>
    </ul>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    
    <script src="js/animation.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/docs.min.js"></script>
    <script src="js/ie10-viewport-bug-workaround.js"></script>

    <script type="text/javascript">
    $(function(){
    	$(document).ready(function(){
    		$('#employer_div').hide();
			$('#employer').change(function() {
			   if($(this).is(":checked")) {
			      //'checked' event code
			     //hide
			      $('#employer_div').show();
			      return;
			   }
			   //'unchecked' event code
			   	  $('#employer_div').hide();
			});
    	});
    });
	
	
	
    </script>

</body>
</html>